Matlab如何打开nc文件?

纯干货,请收下!

%Matlab程序读取sst数据: 
close all
clear all

oid='sst.mnmean.nc'              %将oid设置为nc文件名,防止nc文件名过长导致不必要的麻烦 以下用oid代替nc文件名
ncinfo('sst.mnmean.nc');        %读取nc文件的属性值 必须保证nc文件和.m程序在同一文件夹下
sst=double(ncread(oid,'sst'));  %读取文件类型为sst类型的nc文件 
nlat=double(ncread(oid,'lat')); %读取经度变量
nlon=double(ncread(oid,'lon')); %读取纬度变量
 
mv=ncreadatt(oid,'/sst','missing_value');  %缺少值和对应精度
sst(find(sst==mv))=NaN;         %将缺少值设置为空值
 %% 显示数据
[x,y]=meshgrid(lon,lat);%根据经纬度信息产生格网,
[Nlt,Nlg]=meshgrid(nlat,nlon);  
%Plot the SST data without using the MATLAB Mapping Toolbox
%用Plot方法对sst文件进行画图不使用MATLAB自带的地图工具  结果:显示不出来对应的横纵坐标和轮廓
figure
pcolor(Nlg,Nlt,sst(:,:,1));shading interp;
load coast;hold on;plot(long,lat);plot(long+360,lat);hold off
colorbar
%用Plot方法对sst文件进行画图不使用MATLAB自带的地图工具  结果:显示不出来对应的横纵坐标和轮廓
%Plot the SST data using the MATLAB Mapping Toolbox
 
figure
axesm('eqdcylin','maplatlimit',[-80 80],'maplonlimit',[0 360]);  % Create a cylindrical equidistant map  %根据nc文件创建相应的图,此处创建eqdcylin即创建柱面等距地图  还可创建其他类型图 自行查找axesm属性资源
pcolorm(Nlt,Nlg,sst(:,:,1))           % pseudocolor plot "stretched" to the grid   用matlab自带工具伪彩色图“拉伸”到网格  
load coast                                 % add continental outlines  可以用matlab自带工具添加大陆轮廓
plotm(lat,long)
colorbar

  • 8
    点赞
  • 69
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
此竞赛题有解压密码,下载后点击“管理密码”按钮就能看到,包含各种竞赛要求,从A到F全有各种附件说明,竞赛中遇到的各种问题,都可以找这个论坛专家探讨! https://www.shumo.com/forum/forum.php?mod=forumdisplay&fid=113&tdsourcetag=s_pctim_aiomsg 附件数据说明: (1) 加拿大各地天气的历史数据: eng-daily-01011987-12311987.csv; http://climate.weather.gc.ca/historical_data/search_historic_data_e.html(题目只提供了样例数据,更多数据请自行下载。建模中也可以下载其它地区数据进行研究) (2) 海洋表面温度(SST data): sst.mnmean.nc;(data provided by the NOAA/OAR/ESRL PSD, Boulder, Colorado, USA, from their Web site at https://www.esrl.noaa.gov/psd/) https://www.esrl.noaa.gov/psd/data/gridded/using_dods.html(数据可以通过多种方式读取,其中Matlab代码见附件:ReadSSTnc.m) 参考文献 1. Y. Xu, V. Ramanathan, D. G. Victor, Global warming will happen faster than we think, Nature, Vol. 564, 30:32, 2018, Dec. 2. D. Spratt, I. Dunlop, Existential climate-related security risk: A scenario approach, 2019 May, Policy Paper from Breakthrough-National Centre for Climate Restoration 3. C. Quere, R. Andrew, et al, Global carbon budget 2017, Earth Syst. Sci. Data,2018, 405-448 4. I. Medhaug, M. B. Stolpe, E. M. Fischer & R. Knutti, Reconciling controversies about the ‘global warming hiatus’, 2017, Nature 5. G. A. Meehl, A. Hu, B. D. Santer & S. Xie, Contribution of the interdecadal Pacific Oscillation to twentieth-century global surface temperature tends, Nature Climate Change, 6, 1005-1008 (2016) 6. X. Chen & K. K. Tung, Global surface warming enhanced by weak Atlantic overturning circulation, 2018, Nature 7. T. M. Smith, R. W. Reynolds, A high-resolution global sea surface temperature climatology for the 1961-90 base period, J. Climate, 1998, 3320-3323

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

浪潮之巅的小萝卜头

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值